package com.itheima.mapper;

import com.itheima.domain.Trip;
import com.itheima.domain.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public interface TripMapper {
    //查询行程表中所有的数据
    @Select("select tb_trip.id,tb_trip.username,tb_trip.gender,tb_trip.idcard,tb_trip.from_address fromAddress,tb_trip.to_address toAddress,tb_trip.start_time startTime from tb_trip")
    public List<Trip> queryTripAll();
    //添加用户过年的形成数据
    @Insert("insert into tb_trip values(#{id},#{username},#{gender},#{idcard},#{fromAddress},#{toAddress},#{startTime})")
    public void addTrip(Trip trip);
    //根据ID查询用户的行程数据
    @Select("select tb_trip.id,tb_trip.username,tb_trip.gender,tb_trip.idcard,tb_trip.from_address fromAddress,tb_trip.to_address toAddress,tb_trip.start_time startTime  from tb_trip where id = #{id}")
    public Trip queryTripById(int id);
    //根据ID修改用户的行程数据
    @Update("update tb_trip set username = #{username},gender = #{gender},idcard = #{idcard},from_address = #{fromAddress},to_address = #{toAddress},start_time = #{startTime} where id = #{id}")
    public void updateTripById(Trip trip);
    //根据ID删除用户的行程数据
    @Delete("delete from tb_trip where id= #{id}")
    public void deleteTripById(int id);
}
